package com.mr.service.impl;

import org.springframework.stereotype.Service;

import com.mr.model.BaseInfo;
import com.mr.model.Goods;
import com.mr.model.GoodsOrder;
import com.mr.service.GoodsService;

@Service("goodsService")
public class GoodsServiceImpl extends BaseServiceImpl implements GoodsService{

	public void saveOrder(BaseInfo base, Goods goods, Integer quantity) {
		GoodsOrder order = new GoodsOrder(base.getId(), goods.getId(), quantity, goods.getPrice());
		baseDao.saveObject(order);
		goods.buyGoods(quantity);
		baseDao.saveObject(goods);
		Goods newgoods = new Goods(base.getId(), quantity, goods);
		baseDao.saveObject(newgoods);
	}

}
